﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace TMI85303.UI.Cov
{
    /// <summary>
    /// 使用在RadioButton按钮的枚举值和int之间的转化
    /// </summary>
    public class EnumToIntConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 检查绑定的值是否等于枚举的整数值
            return (int)value == (int)parameter;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 如果RadioButton被选中，返回其枚举值的int表示
            return value.Equals(true) ? (int)parameter : Binding.DoNothing;
        }
    }
}
